package top.lingkang;


import top.lingkang.finalpool.FinalPoolConfig;
import top.lingkang.finalpool.FinalPoolUtils;

import java.sql.ResultSet;
import java.sql.SQLException;

public class Test {

    public static void main(String[] args) {
        FinalPoolConfig finalPoolConfig = new FinalPoolConfig();
        finalPoolConfig.setUrl("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai");
        finalPoolConfig.setDriver("com.mysql.jdbc.Driver");
        finalPoolConfig.setUsername("root");
        finalPoolConfig.setPassword("123456");
        FinalPoolUtils.init(finalPoolConfig);

        ResultSet query = FinalPoolUtils.query("select * from t_user");
        try {
            while (query.next()) {
                String username = query.getString("username");
                System.out.println(username);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        FinalPoolUtils.update("update t_user set nickname=? where id=1", new Object[]{String.valueOf(System.currentTimeMillis())});
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
